package org.gruposp2p.proyectokarma.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.GeneratedValue;

import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.Resolution;

@Entity
@Table(name="Address")
public class Address  implements java.io.Serializable {

	 private static final long serialVersionUID = 1L;
	 
	 @Id @GeneratedValue(strategy=IDENTITY)
     @Column(name="id", unique=true, nullable=false)
     private Long id;
     @Column(name="value", nullable=false)
     private String value;
     @Column(name="postalCode", nullable=false, length=50)
     private String postalCode;
     @Column(name="locality", nullable=false, length=50)
     private String locality;
     @Column(name="province", nullable=false, length=50)
     private String province;
     @Column(name="country", nullable=false, length=50)
     private String country;
     @DateBridge( resolution = Resolution.DAY )
     @Temporal(TemporalType.TIMESTAMP)
     @Column(name="dateCreated", length=23)
     private Date dateCreated;
     @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="address")
     private Set<PeerAddress> peerAddresses = new HashSet<PeerAddress>(0);

    public Address() { }
	
    public Address(Long id, String value, String postalCode, 
    		String locality, String province, String country) {
        this.id = id;
        this.value = value;
        this.postalCode = postalCode;
        this.locality = locality;
        this.province = province;
        this.country = country;
    }

    public Address(Long id, String value, String postalCode, String locality, String province, 
    		String country, Set<PeerAddress> peerAddresses) {
       this.id = id;
       this.value = value;
       this.postalCode = postalCode;
       this.locality = locality;
       this.province = province;
       this.country = country;
       this.peerAddresses = peerAddresses;
    }
 
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getValue() {
        return this.value;
    }
    
    public void setValue(String value) {
        this.value = value;
    }
    
    public String getPostalCode() {
        return this.postalCode;
    }
    
    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }
    
    public String getLocality() {
        return this.locality;
    }
    
    public void setLocality(String locality) {
        this.locality = locality;
    }
    
    public String getProvince() {
        return this.province;
    }
    
    public void setProvince(String province) {
        this.province = province;
    }
    
    public String getCountry() {
        return this.country;
    }
    
    public void setCountry(String country) {
        this.country = country;
    }

    public Set<PeerAddress> getPeerAddresses() {
        return this.peerAddresses;
    }
    
    public void setPeerAddresses(Set<PeerAddress> peerAddresses) {
        this.peerAddresses = peerAddresses;
    }

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

}


